package com.xy.controller.order;

import com.xy.api.model.dto.order.PlaceFollowOrderDTO;
import com.xy.api.model.request.order.PFORequest;
import com.xy.api.model.response.R;
import com.xy.api.model.response.Rows;
import com.xy.api.service.mainData.IProductService;
import com.xy.api.service.order.IPlaceFollowOrderService;
import com.xy.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/placeFollowOrder")
public class PFOController extends BaseController {

    @Autowired
    private IPlaceFollowOrderService placeFollowOrderService;

    @Autowired
    private IProductService productService;

    @PostMapping("/queryList")
    public R queryPlaceFollowOrderList(@RequestBody PFORequest request) {
        Rows<PlaceFollowOrderDTO> rows = placeFollowOrderService.queryPlaceFollowOrderList(request);
        return success(rows);
    }

    @PostMapping("/detail")
    public R<PlaceFollowOrderDTO> placeFollowOrderDetail(@RequestBody PFORequest request) {
        PlaceFollowOrderDTO placeFollowOrder = placeFollowOrderService.placeFollowOrderDetail(request.getId());
        return success(placeFollowOrder);
    }

    @PostMapping("/edit")
    public R<PlaceFollowOrderDTO> editPlaceFollowOrder(@RequestBody PlaceFollowOrderDTO request) {
        PlaceFollowOrderDTO placeFollowOrder = placeFollowOrderService.editPlaceFollowOrder(request);
        return success(placeFollowOrder);
    }

    @PostMapping("/delete")
    public R deletePlaceFollowOrder(@RequestBody PlaceFollowOrderDTO request) {
        placeFollowOrderService.deletePlaceFollowOrder(request.getId());
        return success();
    }

}
